package com.train.daily.api;

import com.train.common.resp.CommonResp;
import com.train.daily.dto.token.DailyTrainSkTokenValidDTO;
import com.train.daily.dto.token.DailyTrainTokenQueryLeftDTO;
import com.train.daily.resp.token.DailyTrainTokenQueryLeftResp;
import com.train.daily.service.DailyTrainSkTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DailyTrainSkTokenApiImpl implements DailyTrainSkTokenApi {

    @Autowired
    private DailyTrainSkTokenService dailyTrainSkTokenService;

    @Override
    public CommonResp decrementSkToken(DailyTrainSkTokenValidDTO dto) {
        dailyTrainSkTokenService.decrementSkToken(dto);
        return CommonResp.ok();
    }

    @Override
    public CommonResp getSkToken(DailyTrainTokenQueryLeftDTO dto) {
        Long leftToken = dailyTrainSkTokenService.getSkToken(dto);
        return CommonResp.ok(new DailyTrainTokenQueryLeftResp(leftToken));
    }
}
